#!/bin/bash

#
# Copyright (c) 2014-2015 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#

[ x$(which grep) = x ] && exit -1

num_cpus=$(\grep -c "^processor" /proc/cpuinfo)

if [ x${ZEPHYR_JOBS} = x ]; then
	ZEPHYR_JOBS=$((${num_cpus} * 2 + 1))
fi

echo Using $ZEPHYR_JOBS threads
nice make --jobs=${ZEPHYR_JOBS} --load-average=${num_cpus} $@
